package com.suxin.validator;

import com.suxin.validator.annotation.MaxAnnotation;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.Map;

/**
 * @author Tang
 * @classname MainTest
 * @description [  ]
 * @date 2023/1/7 15:12
 */
public class MainTest {

    @Data
    static class User {

        @NotNull(message = "不能为null!")
        private String name;

        @MaxAnnotation(max = 20,isRequire = true,message = "太大了！")
        private Integer age;
    }

    public static void main(String[] args) {
        User user = new User();
//        user.setAge(21);
        JavaxValidator javaxValidator = new JavaxValidator();
        Map<String, String> msg = javaxValidator.validatorBean(user);
        msg.forEach((key,value) -> {
            System.out.println("key=" + key + ",value=" + value);
        });
        String nameMsg = javaxValidator.validateProperty(user, "name");
        System.out.println(nameMsg);
    }

}
